﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MF.Data.Entity;
using MF.Repository;
using MF.EFRepository.Entities;
using MF.Data;

namespace MF.EFRepository.Repository
{
    public class OrderRepository : EntityRepository<Order>, IOrderRepository
    {
        public OrderRepository(IDbContextManager manager) : base(manager) { }

        protected override IQueryable<Order> BuildQuery(System.Data.Objects.ObjectQuery<Order> query)
        {
            return query.Include("OrderDetails").Where(o => o.Customer.Active);
        }

        public IQueryable<Order> QueryByCustomer(int customerId)
        {
            return this.Query().Where(o => o.Customer.Id == customerId);
        }
    }

}
